package com.hyt.it.ogt.controller.ykcj.analysis;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyt.common.apiInfor.DataType;
import com.hyt.common.apiInfor.ParamType;
import com.hyt.it.ogt.controller.base.BaseController;
import com.hyt.it.ogt.ykcj.common.constant.HttpStatus;
import com.hyt.it.ogt.ykcj.common.core.domain.AjaxResult;
import com.hyt.it.ogt.ykcj.feign.model.TaskCandidateAreaVO;
import com.hyt.it.ogt.ykcj.service.exchange.IAreaService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiSort;

/**
 * description
 *
 * @author yaojian
 * @createTime 2021/12/31
 */
@Api(tags = "ExamArea.17.区域类", value = "区域类")
@ApiSort(value = 212)
@RestController
@RequestMapping("/exam/area")
public class ExamAreaController extends BaseController {

    @Autowired
    private IAreaService areaService;

    /**
     * 获取考试分数段信息
     */
    @ApiOperation("根据考试id获取省份信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "examId", value = "考试id", dataType = DataType.STRING, paramType = ParamType.PATH, required = true),

    })
    @ApiResponses({
            @ApiResponse(code = HttpStatus.SUCCESS, message = "OK", response = TaskCandidateAreaVO.class),
    })
    @GetMapping(value = "/{examId}")
    public AjaxResult get(@PathVariable(value = "examId", required = true) String examId) {
        List<TaskCandidateAreaVO> candidateProvinceByTaskId = areaService.getCandidateProvinceByExamId(examId);
        return AjaxResult.success(candidateProvinceByTaskId);
    }

    /**
     * 根据任务id和省份获取市信息
     */
    @ApiOperation("根据考试id和省份编码获取市信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "examId", value = "考试id", dataType = DataType.STRING, paramType = ParamType.PATH, required = true),
            @ApiImplicitParam(name = "provinceCode", value = "省份编码", dataType = DataType.STRING, paramType = ParamType.PATH, required = true),
    })
    @ApiResponses({
            @ApiResponse(code = HttpStatus.SUCCESS, message = "OK", response = TaskCandidateAreaVO.class),
    })
    @GetMapping(value = "/{examId}/{provinceCode}")
    public AjaxResult get(@PathVariable(value = "examId", required = true) String examId,
                          @PathVariable(value = "provinceCode", required = true) String provinceCode) {
        List<TaskCandidateAreaVO> candidateProvinceByTaskId = areaService.getCandidateCityByExamId(examId, provinceCode);
        return AjaxResult.success(candidateProvinceByTaskId);
    }

}
